package com.yserp.project.erp.record.checkorderlog.controller;

import java.util.List;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import com.yserp.framework.aspectj.lang.annotation.Log;
import com.yserp.framework.aspectj.lang.enums.BusinessType;
import com.yserp.project.erp.record.checkorderlog.domain.CheckOrderLog;
import com.yserp.project.erp.record.checkorderlog.service.ICheckOrderLogService;
import com.yserp.framework.web.controller.BaseController;
import com.yserp.framework.web.domain.AjaxResult;
import com.yserp.common.utils.poi.ExcelUtil;
import com.yserp.framework.web.page.TableDataInfo;

/**
 * 订单审核日记Controller
 * 
 * @author yserp
 * @date 2022-07-07
 */
@Controller
@RequestMapping("/record/checkorderlog")
public class CheckOrderLogController extends BaseController
{
    private String prefix = "record/checkorderlog";

    @Autowired
    private ICheckOrderLogService checkOrderLogService;

    @RequiresPermissions("record:checkorderlog:view")
    @GetMapping()
    public String checkorderlog()
    {
        return prefix + "/checkorderlog";
    }

    /**
     * 查询订单审核日记列表
     */
    @RequiresPermissions("record:checkorderlog:list")
    @PostMapping("/list")
    @ResponseBody
    public TableDataInfo list(CheckOrderLog checkOrderLog)
    {
        startPage();
        List<CheckOrderLog> list = checkOrderLogService.selectCheckOrderLogList(checkOrderLog);
        return getDataTable(list);
    }

    /**
     * 导出订单审核日记列表
     */
    @RequiresPermissions("record:checkorderlog:export")
    @Log(title = "订单审核日记", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    @ResponseBody
    public AjaxResult export(CheckOrderLog checkOrderLog)
    {
        List<CheckOrderLog> list = checkOrderLogService.selectCheckOrderLogList(checkOrderLog);
        ExcelUtil<CheckOrderLog> util = new ExcelUtil<CheckOrderLog>(CheckOrderLog.class);
        return util.exportExcel(list, "订单审核日记数据");
    }

    /**
     * 新增订单审核日记
     */
    @GetMapping("/add")
    public String add()
    {
        return prefix + "/add";
    }

    /**
     * 新增保存订单审核日记
     */
    @RequiresPermissions("record:checkorderlog:add")
    @Log(title = "订单审核日记", businessType = BusinessType.INSERT)
    @PostMapping("/add")
    @ResponseBody
    public AjaxResult addSave(CheckOrderLog checkOrderLog)
    {
        return toAjax(checkOrderLogService.insertCheckOrderLog(checkOrderLog));
    }

    /**
     * 修改订单审核日记
     */
    @RequiresPermissions("record:checkorderlog:edit")
    @GetMapping("/edit/{id}")
    public String edit(@PathVariable("id") Long id, ModelMap mmap)
    {
        CheckOrderLog checkOrderLog = checkOrderLogService.selectCheckOrderLogById(id);
        mmap.put("checkOrderLog", checkOrderLog);
        return prefix + "/edit";
    }

    /**
     * 修改保存订单审核日记
     */
    @RequiresPermissions("record:checkorderlog:edit")
    @Log(title = "订单审核日记", businessType = BusinessType.UPDATE)
    @PostMapping("/edit")
    @ResponseBody
    public AjaxResult editSave(CheckOrderLog checkOrderLog)
    {
        return toAjax(checkOrderLogService.updateCheckOrderLog(checkOrderLog));
    }

    /**
     * 删除订单审核日记
     */
    @RequiresPermissions("record:checkorderlog:remove")
    @Log(title = "订单审核日记", businessType = BusinessType.DELETE)
    @PostMapping( "/remove")
    @ResponseBody
    public AjaxResult remove(String ids)
    {
        return toAjax(checkOrderLogService.deleteCheckOrderLogByIds(ids));
    }
}
